<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <table class="layui-hide" id="<{$page_id}>_table-page" lay-filter="<{$page_id}>_currentTableFilter"></table>
        <script type="text/html" id="<{$page_id}>_currentTableFilter">
            <{if AdminUsersModel::check_right("$module/$controller/delrecord")}>
            <a class="layui-btn layui-btn-xs" lay-event="delrecord">删除</a>
            <{/if}>
        </script>

        <script type="text/html" id="<{$page_id}>_toolbarDemo">
            <div class="layui-btn-container">
                <{if AdminUsersModel::check_right("$module/$controller/set")}>
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="set">新增解析
                </button>
                <{/if}>
            </div>
        </script>
    </div>
</div>

<script type="text/javascript">
    layui.use(['form', 'table', 'miniPage', 'element'], function () {
        var table = layui.table;
        var miniPage = layui.miniPage;
        table.render({
            elem: '#<{$page_id}>_table-page'
            , toolbar: '#<{$page_id}>_toolbarDemo'
            , defaultToolbar: ['filter', 'exports']
            , url: '/<{$module}>/<{$controller}>/<{$action}>?do=list&isajax=1&DomainName=<{$DomainName}>&groupid=<{$groupid}>'
            , limit: 30
            , height: 'full-290'//一行条件
            , cols: [[
                {field: 'RecordId',title: 'ID',width:200}
                , {field: 'RR', title: "主机头",width:120}
                , {field: 'Type', title: "类型",width:100}
                , {field: 'Value', title: "值"}
                , {field: 'Status', title: "状态",width:100}
                , {align: 'left', fixed: 'right', toolbar: '#<{$page_id}>_currentTableFilter',width:120}
            ]]
            , page: true
        });

        var $ = layui.$, active = {
            set: function () {
                var content = miniPage.getHrefContent('/<{$module}>/<{$controller}>/set?&groupid=<{$groupid}>&DomainName=<{$DomainName}>');
                var index = layer.open({
                    title: '解析域名 <{$DomainName}>'
                    , type: 1
                    , shade: 0.5
                    , area: ['40%', '450px']
                    , shadeClose: true
                    , content: content
                    , btn: ['确定', '取消']
                    , yes: function (index, layero) {
                        layero.find("#form-submit").click();
                    }
                });
            }
            ,delrecord: function (obj) {
                var data = obj.data;
                var index = layer.confirm('删除此条解析记录?', function (index) {
                    $.post('/<{$module}>/<{$controller}>/delrecord',{groupid:'<{$groupid}>',RecordId:data.RecordId},function (json) {
                        layer.msg(json.msg);
                        if (json.code == 0){
                            table.reload('<{$page_id}>_table-page');
                            layer.close(index);
                        }

                    },'json')
                });
            }
        };
        //监听工具条
        table.on('tool(<{$page_id}>_currentTableFilter)', function (obj) {
            var type = obj.event;
            active[type] ? active[type].call(this, obj) : '';
        });
        table.on('toolbar(<{$page_id}>_currentTableFilter)', function (obj) {
            var type = obj.event;
            active[type] ? active[type].call(this, obj) : '';
        });
    });
</script>